
%Declare the symbolic variables (syms)
syms OmegabVal shkaVal lambdaprimeVal lambdaVal OmegagprimeVal shksprimeVal phiprimeVal OmegabprimeVal

f= Omegab*exp(OmegabVal)- yb*shkaVal+b/(Lambdastar*exp(lambdaVal)) ...
-(1-delta)*bet*Lambdastar*exp(lambdaprimeVal)/(Lambdastar*exp(lambdaVal))*...
(Omegag*exp(OmegagprimeVal)+shksprimeVal*phiprimeVal*xig*(Omegag*exp(OmegagprimeVal)-Omegab*exp(OmegabprimeVal)));

%Take symbolic derivatives
dd1 = diff(f,OmegabVal);
dd2 = diff(f,shkaVal);
dd3 = diff(f,lambdaprimeVal);
dd4 = diff(f,lambdaVal);
dd5 = diff(f,OmegagprimeVal);
dd6 = diff(f,shksprimeVal);
dd7 = diff(f,phiprimeVal);
dd8 = diff(f,OmegabprimeVal);

%Evaluates symbolic derivatives

OmegabVal=0;       %loglin
shkaVal=s;         %linearize
lambdaprimeVal=0;  %lin
lambdaVal=0;       %loglin
OmegagprimeVal=0;  %loglin
shksprimeVal=s;    %linearize
phiprimeVal=s;     %linearize
OmegabprimeVal=0;  %loglin


D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
D4=subs(dd4);
D5=subs(dd5);
D6=subs(dd6);
D7=subs(dd7);
D8=subs(dd8);

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
d4=double(D4);
d5=double(D5);
d6=double(D6);
d7=double(D7);
d8=double(D8);

ACont(2,OmegabLog)   = d1;
ACont(2,shkaLog)     = d2;
ALead(2,LambdaLog)   = d3;
ACont(2,LambdaLog)   = d4;
ALead(2,OmegagLog)   = d5; 
ALead(2,shksLog)     = d6;
ALead(2,phiLog)      = d7;
ALead(2,OmegabLog)   = d8;

